from datetime import datetime

from django.db import models

class Movie(models.Model):
    # movieId=models.IntegerField('电影ID',default=0,)
    name=models.CharField('电影名称',max_length=50)
    fav_nums=models.IntegerField('收藏人数',default=0)
    click_nums=models.IntegerField('点击数',default=0)
    add_time=models.DateTimeField('添加时间',default=datetime.now)


    class Meta:
        verbose_name="电影"
        verbose_name_plural=verbose_name

    def __str__(self):
        return self.name


class MovieParticulars(models.Model):
    MOVIE_TYPE=(
        ('aq', u'爱情'),
        ('jq', u'剧情'),
        ('xj', u'喜剧'),
        ('wx', u'武侠'),
        ('dz', u'动作'),
        ('xy', u'悬疑'),
        ('kb', u'恐怖'),
        ('fz', u'犯罪'),
        ('js', u'惊悚'),
        ('kh', u'科幻'),
        ('mx', u'冒险'),
        ('dm', u'动漫'),
        ('ty', u'体育'),
        ('jl', u'记录'),
        ('zz', u'战争')
    )

    REGION=(
        ('zg',u'中国'),
        ('hg',u'韩国'),
        ('rb',u'日本'),
        ('om',u'欧美')
    )

    LANGUAGE=(
        ('chinese',u'国语'),
        ('cantonese',u'粤语'),
        ('japanese',u'日语'),
        ('korean',u'韩语'),
        ('english',u'英语'),
        ('french',u'法语'),
        ('portuguese',u'葡萄牙语'),
        ('spanish', u'西班牙语')
    )
    name=models.ForeignKey(Movie,verbose_name='电影',on_delete=models.CASCADE)
    image = models.ImageField('封面图', upload_to='movies/images/%Y/%m', default='images/c3.jpg', max_length=300)
    movie_type=models.CharField(verbose_name='类型',choices=MOVIE_TYPE,default='爱情',max_length=10)
    director=models.CharField('导演',max_length=20)
    protagonist=models.CharField('主演',max_length=20)
    region=models.CharField(verbose_name=u'地区/国家',choices=REGION,default='zg',max_length=10)
    language=models.CharField(verbose_name=u'语言',choices=LANGUAGE,default='chinese',max_length=10)
    release_data=models.DateTimeField('上映时间',default=datetime.now)
    intro=models.TextField('简介')
    add_time = models.DateTimeField("添加时间", default=datetime.now)

    class Meta:
        verbose_name='电影详情'
        verbose_name_plural=verbose_name

    def __str__(self):
        return self.movie_type


class MovieResourse(models.Model):
    name=models.ForeignKey(Movie,verbose_name="电影",on_delete=models.CASCADE)
    download = models.FileField("资源文件", upload_to="movies/resource/%Y/%m", max_length=100)
    add_time = models.DateTimeField("添加时间", default=datetime.now)

    class Meta:
        verbose_name='电影资源'
        verbose_name_plural=verbose_name


